<?php /* Smarty version Smarty-3.1.18, created on 2017-09-05 23:07:28
         compiled from "/Applications/MAMP/htdocs/PHP/jifenshop/protected/template/wap/goods.detail.html" */ ?>
<?php /*%%SmartyHeaderCode:1833165679597350dcd489b7-45343506%%*/if(!defined('SMARTY_DIR')) exit('no direct access allowed');
$_valid = $_smarty_tpl->decodeProperties(array (
  'file_dependency' => 
  array (
    '096bd3a34c1da25392df35e4fc4a567d610f6a39' => 
    array (
      0 => '/Applications/MAMP/htdocs/PHP/jifenshop/protected/template/wap/goods.detail.html',
      1 => 1504624046,
      2 => 'file',
    ),
  ),
  'nocache_hash' => '1833165679597350dcd489b7-45343506',
  'function' => 
  array (
  ),
  'version' => 'Smarty-3.1.18',
  'unifunc' => 'content_597350dcea6749_41181103',
  'variables' => 
  array (
    'data' => 0,
    'p' => 0,
    'integral' => 0,
    'g' => 0,
  ),
  'has_nocache_code' => false,
),false); /*/%%SmartyHeaderCode%%*/?>
<?php if ($_valid && !is_callable('content_597350dcea6749_41181103')) {function content_597350dcea6749_41181103($_smarty_tpl) {?><?php echo $_smarty_tpl->getSubTemplate ("header.html", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array(), 0);?>

<style type="text/css">
	.content img{ width: 100% !important;height: auto !important;}
</style>
<body class="gr">

<div class="navBar navBar-hidden">
	<a class="left" href="javascript:history.back()"><i class="return-back"></i></a>
	<div class="titleView">商品详情</div>
</div>

<div class="goods-detail main-bottom width-wrap">
	<div class="pics">
		<?php if (count($_smarty_tpl->tpl_vars['data']->value->pics)) {?>
		<div class="slide">
			<ul>
				<?php  $_smarty_tpl->tpl_vars['p'] = new Smarty_Variable; $_smarty_tpl->tpl_vars['p']->_loop = false;
 $_from = $_smarty_tpl->tpl_vars['data']->value->pics; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
foreach ($_from as $_smarty_tpl->tpl_vars['p']->key => $_smarty_tpl->tpl_vars['p']->value) {
$_smarty_tpl->tpl_vars['p']->_loop = true;
?>
				<li title="<?php echo $_smarty_tpl->tpl_vars['p']->value->memo;?>
"><div><a href="javascript:void(0)"><img src="<?php echo $_smarty_tpl->tpl_vars['p']->value->pic;?>
" /></a></div></li>
				<?php } ?>
			</ul>
		</div>
		<div class="pager"></div>
		<?php } else { ?>
		<div class="pic" style="background-image:url(<?php echo $_smarty_tpl->tpl_vars['data']->value->default_pic;?>
);"></div>
		<?php }?>
	</div>
	<div class="detail">
		<div class="name"><?php echo $_smarty_tpl->tpl_vars['data']->value->name;?>
</div>
		<?php if (!isset($_smarty_tpl->tpl_vars['integral']->value)) {?>
		<div class="price ge-bottom ge-light">
			<div><span>￥<?php echo number_format($_smarty_tpl->tpl_vars['data']->value->price,2);?>
</span>　<s>原价￥<?php echo number_format($_smarty_tpl->tpl_vars['data']->value->market_price,2);?>
</s></div>
		</div>
		<div class="country">
			<!--<span><?php echo $_smarty_tpl->tpl_vars['data']->value->sale_method_name;?>
</span>-->
			<div></div>
			<font><?php if ($_smarty_tpl->tpl_vars['data']->value->sale_method==1) {?>此商品线下门店有售<?php }?></font>
		</div>
		<?php } else { ?>
		<div class="integral"><?php echo $_smarty_tpl->tpl_vars['data']->value->integral;?>
积分</div>
		<?php }?>
	</div>
	
	<div class="param">
		<div class="ico1"></div>
		<span>人气 <?php echo $_smarty_tpl->tpl_vars['data']->value->clicks;?>
</span>
		<div class="ico2"></div>
		<span>销量 <?php echo $_smarty_tpl->tpl_vars['data']->value->sales;?>
</span>
		<div class="ico3"></div>
		<span class="label3">库存 <?php echo $_smarty_tpl->tpl_vars['data']->value->stocks;?>
</span>
	</div>
	
	<div class="detail-param">
		<ul>
			<li>
				<font>规格：</font>
				<?php  $_smarty_tpl->tpl_vars['g'] = new Smarty_Variable; $_smarty_tpl->tpl_vars['g']->_loop = false;
 $_from = $_smarty_tpl->tpl_vars['data']->value->specs; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
foreach ($_from as $_smarty_tpl->tpl_vars['g']->key => $_smarty_tpl->tpl_vars['g']->value) {
$_smarty_tpl->tpl_vars['g']->_loop = true;
?>
				<span><input type="radio" name="spec" id="spec<?php echo $_smarty_tpl->tpl_vars['g']->value->id;?>
" value="<?php echo $_smarty_tpl->tpl_vars['g']->value->spec;?>
" price="<?php echo $_smarty_tpl->tpl_vars['g']->value->price;?>
" /><label for="spec<?php echo $_smarty_tpl->tpl_vars['g']->value->id;?>
"><div><?php echo $_smarty_tpl->tpl_vars['g']->value->spec;?>
</div></label></span>
				<?php } ?>
				<div class="clear"></div>
			</li>
			<?php if (!isset($_smarty_tpl->tpl_vars['integral']->value)) {?>
			<li>
				<font>数量：</font>
				<div class="num">
					<a href="javascript:void(0)" class="minus">-</a>
					<input type="tel" id="quantity" value="1" stocks="<?php echo $_smarty_tpl->tpl_vars['data']->value->stocks;?>
" />
					<a href="javascript:void(0)" class="plus">+</a>
				</div>
				<div class="clear"></div>
			</li>
			<?php }?>
		</ul>
	</div>
	
	<?php if (!isset($_smarty_tpl->tpl_vars['integral']->value)) {?>
	<a href="wap.php?app=comment&act=index&goods_id=<?php echo $_smarty_tpl->tpl_vars['data']->value->id;?>
&pagesize=10" class="comments push-ico">
		<font>查看评论</font><div>用户评价</div><span>(<?php echo $_smarty_tpl->tpl_vars['data']->value->comments;?>
)</span>
	</a>
	<?php }?>
	
	<div class="memo">
		<div class="tip">商品详情</div>
		<div class="content">
			<?php echo $_smarty_tpl->tpl_vars['data']->value->content;?>

		</div>
	</div>
	
	<?php if (!isset($_smarty_tpl->tpl_vars['integral']->value)) {?>
	<div class="bottomView toolBar-black ge-top">
		<a class="btn" href="javascript:void(0)">加入购物车</a>
		<!--<a class="im" href="javascript:void(0)" member_id="xxx"></a>-->
		<a class="fav <?php if ($_smarty_tpl->tpl_vars['data']->value->favorited==1) {?>fav-x<?php }?>" href="javascript:void(0)"></a>
		<a class="cart badge" href="wap.php?app=cart&act=index"><sub></sub></a>
	</div>
	<?php } else { ?>
	<a class="integralBtn" href="javascript:void(0)">立即兑换</a>
	<?php }?>
</div>

<input type="hidden" id="goods_id" value="<?php echo $_smarty_tpl->tpl_vars['data']->value->id;?>
" />

<?php if (isset($_smarty_tpl->tpl_vars['integral']->value)) {?>
<form action="wap.php?app=cart&act=jiesuan" method="post">
<input type="hidden" name="goods" id="goods" />
<input type="hidden" name="integral_order" value="1" />
</form>
<?php }?>

<?php echo $_smarty_tpl->getSubTemplate ("footer.html", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array(), 0);?>

<script>
function getCart(){
	$.getJSON('api.php?app=cart&act=cart_total', function(json){
		$('.badge sub').html(json.data.quantity>0?'<b>'+json.data.quantity+'</b>':'');
	});
}
function resize(){
	$('.goods-detail .pics, .goods-detail .pics .pic, .goods-detail .slide').autoHeight(640, 640);
	$('.goods-detail .slide').touchmove({
		title : 'title',
		drag : true,
		keydown : true,
		pager : '.pics .pager',
		offset : 'center',
		complete : function(){
			$('.pics li div').loadpic({ fill:this.height() });
		}
	});
}
$(window).resize(resize);
$(function(){
	resize();
	$(window).scroll(function(){
		if($(window).scrollTop()>=$('.pics').height()-$('.navBar').height()){
			$('.navBar').removeClass('navBar-hidden');
		}else{
			$('.navBar').addClass('navBar-hidden');
		}
	});
	
	<?php if (!isset($_smarty_tpl->tpl_vars['integral']->value)) {?>
	getCart();
	$('.price span').priceFont('bigPrice');
	
	$(':radio:eq(0)').attr('checked', 'checked');
	$('.price span').html('￥'+$(':radio:checked').attr('price').numberFormat(2)).priceFont('bigPrice');
	
	$(':radio').change(function(){
		if(!$(this).is(':checked'))return;
		$('.price span').html('￥'+$(this).attr('price').numberFormat(2)).priceFont('bigPrice');
	});
	
	$('.minus').click(function(){
		var quantity = $('#quantity');
		if(quantity.val()<=1)return;
		quantity.val(quantity.val()*1-1);
	});
	$('.plus').click(function(){
		var quantity = $('#quantity');
		if(quantity.val()*1>quantity.attr('stocks')*1){
			$.overloadError('库存不足');
			return;
		}
		quantity.val(quantity.val()*1+1);
	});
	$('#quantity').focus(function(){
		var quantity = $(this);
		if(quantity.val().length)quantity.data('quantity', quantity.val());
	}).blur(function(){
		var quantity = $(this);
		if(!quantity.val().length){
			$.overloadError('请填写数量');
			quantity.focus();
			return;
		}
		if(quantity.val()*1>quantity.attr('stocks')*1){
			$.overloadError('库存不足');
			quantity.val(quantity.data('quantity'));
			quantity.focus();
			return;
		}
	});
	
	$('.bottomView .im').click(function(){
		var member_id = $(this).attr('member_id');
		location.href = '/wap.php?app=chat&act=talk';
		return false;
	});
	
	$('.bottomView .fav').click(function(){
		var _this = $(this);
		$.postJSON('api.php?app=favorite&act=add', { item_id:'<?php echo $_smarty_tpl->tpl_vars['data']->value->id;?>
', type_id:1 }, function(){
			if(_this.hasClass('fav-x'))_this.removeClass('fav-x');
			else _this.addClass('fav-x');
		});
	});
	
	$('.bottomView .btn').click(function(){
		if($(':radio').length && !$(':radio:checked').length){
			$.overloadError('请选择一个规格');
			return;
		}
		if(!$('#quantity').val().length){
			$.overloadError('请填写数量');
			$('#quantity').focus();
			return;
		}
		var _this = $(this), goods = [{ goods_id:$('#goods_id').val(), quantity:$('#quantity').val(), spec:$(':radio:checked').val() }];
		$.postJSON('api.php?app=cart&act=add_cart', { goods:$.jsonString(goods) }, function(json){
			var dot = $('<div class="badge-dot"></div>'), sub = $('.badge sub'), height = sub.height(), offset = sub.offset(), scrollTop = $(window).scrollTop();
			dot.parabola({
				start : {
					left : _this.offset().left + _this.width()/2,
					top : _this.offset().top + _this.height()/2 - scrollTop,
					width : height,
					height : height
				},
				end : {
					left : offset.left,
					top : offset.top - scrollTop,
				},
				after : function(){
					sub.html(json.data.quantity>0?'<b>'+json.data.quantity+'</b>':'');
					this.remove();
				}
			});
		});
	});
	
	<?php } else { ?>
	$(':radio:eq(0)').attr('checked', 'checked');
	$('.integral').html($(':radio:checked').attr('price').round(0)+'积分');
	
	$(':radio').change(function(){
		if(!$(this).is(':checked'))return;
		$('.integral').html($(this).attr('price').round(0)+'积分');
	});
	$('.integralBtn').click(function(){
		if(!$.checklogin())return;
		var goods = [{ goods_id:$('#goods_id').val(), quantity:1, spec:$(':radio:checked').val() }];
		$('#goods').val($.jsonString(goods));
		$('form').submit();
	});
	<?php }?>
});
</script><?php }} ?>
